with v8.Class_Value, v8.Class_String;
with v8.Class_CPU_Profile;
package v8.Class_CPU_Profiler is
   -- Interface for controlling CPU profiling.

   function Get_Profiles_Count return int;
   -- Returns the number of profiles collected (doesn't include
   -- profiles that are being collected at the moment of call.)

   function Get_Profile
     (index          : int;
      security_token : v8.Class_Value.Pointer := null
     ) return v8.Class_CPU_Profile.Readonly_Pointer;
   -- Returns a profile by index.

   function FindProfile
     (uid            : unsigned;
      security_token : v8.Class_Value.Pointer := null
     ) return v8.Class_CPU_Profile.Readonly_Pointer;
   -- Returns a profile by uid.

   procedure Start_Profiling (title : v8.Class_String.Pointer);
   -- Starts collecting CPU profile. Title may be an empty string. It
   -- is allowed to have several profiles being collected at
   -- once. Attempts to start collecting several profiles with the same
   -- title are silently ignored. While collecting a profile, functions
   -- from all security contexts are included in it. The token-based
   -- filtering is only performed when querying for a profile.

   function Stop_Profiling
     (title          : v8.Class_String.Pointer;
      security_token : v8.Class_Value.Pointer := null
     ) return v8.Class_CPU_Profile.Readonly_Pointer;
   -- Stops collecting CPU profile with a given title and returns it.
   -- If the title given is empty, finishes the last profile started.

   procedure Delete_All_Profiles;
   -- Deletes all existing profiles, also cancelling all profiling
   -- activity.  All previously returned pointers to profiles and their
   -- contents become invalid after this call.


private


   pragma Import (CPP, Get_Profiles_Count, "_ZN2v811CpuProfiler16GetProfilesCountEv");
   pragma Import (CPP, Get_Profile, "_ZN2v811CpuProfiler10GetProfileEiNS_6HandleINS_5ValueEEE");
   pragma Import (CPP, FindProfile, "_ZN2v811CpuProfiler11FindProfileEjNS_6HandleINS_5ValueEEE");
   pragma Import (CPP, Start_Profiling, "_ZN2v811CpuProfiler14StartProfilingENS_6HandleINS_6StringEEE");
   pragma Import (CPP, Stop_Profiling, "_ZN2v811CpuProfiler13StopProfilingENS_6HandleINS_6StringEEENS1_INS_5ValueEEE");
   pragma Import (CPP, Delete_All_Profiles, "_ZN2v811CpuProfiler17DeleteAllProfilesEv");
end v8.Class_CPU_Profiler;
